package com.ctshk.sapp.ship.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.ship.dto.ShipProductDetailDTO2;
import com.ctshk.rpc.ship.dto.ShipProductPageDTO;
import com.ctshk.rpc.ship.dto.ShipProductSaleStrategyDTO;
import com.ctshk.rpc.ship.dto.ShipProductSaleStrategyDTO2;
import com.ctshk.rpc.ship.req.*;
import com.ctshk.rpc.ship.service.IShipProductSaleStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.text.ParseException;
import java.util.List;

/**
 * <p>
 * 船票销售加幅策略 前端控制器
 * </p>
 *
 * @author 刘蕾
 * @since 2021-03-10
 */
@Api(value = "船票销售加幅策略",tags = "產品中心接口API")
@RestController
@RequestMapping("/ship-product-sale-strategy")
public class ShipProductSaleStrategyController extends BaseController {

    @DubboReference
    private IShipProductSaleStrategyService iShipProductSaleStrategyService;



    @ApiOperation(value = "产品中心-船票票管理列表查询", notes = "产品中心-船票票管理列表查询",tags = "产品中心")
    @PostMapping(value = "/query-list")
    public Result<PageResponse<ShipProductPageDTO>> queryList(@RequestBody @Valid ShipProductPageReq shipProductPageReq) {
        return Result.success(iShipProductSaleStrategyService.queryList(shipProductPageReq,getCurrentUser()));
    }



    @ApiOperation(value="船票产品上架加幅设置-新增或修改", notes="船票产品上架加幅设置-新增或修改",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "船票产品上架加幅设置-新增或修改", operDesc = "船票产品上架加幅设置-新增或修改")
    @PostMapping("/save")
    public Result saveShipProductSaleStrategy(@RequestBody @Valid List<ShipProductSaleStrategyReq> reqList) {
        TokenUser user = getCurrentUser(getRequest());
        return iShipProductSaleStrategyService.saveShipProductSaleStrategy(reqList,user);
    }

    @ApiOperation(value="上架保存-新接口", notes="",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.ADD, operTitle = "当地玩乐-产品中心", operDesc = "产品上架")
    @PostMapping("/put-away")
    public Result  putAway(@RequestBody ShipProductBatchSaleStrategyReq LocalFunProductBatchSaleStrategyReq){
        return iShipProductSaleStrategyService.putAway(LocalFunProductBatchSaleStrategyReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="上架编辑页面-新接口", notes="",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.ADD, operTitle = "门票产品上架", operDesc = "门票产品上架")
    @PostMapping("/ship-edit-detail")
    public Result<List<ShipProductSaleStrategyDTO2>>  LocalFunEdit(@RequestBody ShipProductEditReq shipProductEditReq){
        return  iShipProductSaleStrategyService.shipProductEditDetai(shipProductEditReq);
    }

    @ApiOperation(value="批量售价管理", notes="批量售价管理",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "批量售价管理", operDesc = "批量售价管理")
    @PostMapping("/batch/save")
    public Result batchSaveBusProductStrategy(@RequestBody @Valid List<ShipProductSaleStrategyReq> reqList) {
        TokenUser user = getCurrentUser(getRequest());
        return iShipProductSaleStrategyService.batchSaveShipProductSaleStrategy(reqList,user);
    }

    @ApiOperation(value="根据产品id查询产品加幅详情信息", notes="根据产品id查询产品加幅详情信息",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "根据产品id查询产品加幅详情信息", operDesc = "根据产品id查询产品加幅详情信息")
    @GetMapping("/queryByProductId")
    public Result<List<ShipProductSaleStrategyDTO>> queryByProductId(@RequestParam(value = "productId", required = true) Long productId) {
        return Result.success(iShipProductSaleStrategyService.queryByProductId(productId));
    }

    @ApiOperation(value = "推荐设置", notes = "推荐设置",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "推荐设置", operDesc = "推荐设置")
    @PostMapping(value = "/setRecommend")
    public Result setRecommend(@RequestBody @Valid ShipProductReq shipProductReq) {
        TokenUser user = getCurrentUser(getRequest());
        return Result.success(iShipProductSaleStrategyService.setRecommend(shipProductReq,user));

    }


    @ApiOperation(value="根据渠道加幅日期查询产品加幅详情信息", notes="根据渠道加幅日期查询产品加幅详情信息",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "根据渠道加幅日期查询产品加幅详情信息", operDesc = "根据渠道加幅日期查询产品加幅详情信息")
    @PostMapping("/queryByDate")
    public Result<List<ShipProductSaleStrategyDTO>> queryByDate(@RequestBody @Valid ShipProductSaleStrategyQueryReq queryDateReq) {
        return Result.success(iShipProductSaleStrategyService.queryByDate(queryDateReq));
    }


    @ApiOperation(value="产品上架详情", notes="",tags = "产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "景点门票详情", operDesc = "景点门票详情")
    @PostMapping("/query-date-detail")
    public Result<ShipProductDetailDTO2>  queryDateDetail(@RequestBody ShipProductReq2 shipProductReq2) throws ParseException {
        return  iShipProductSaleStrategyService.queryProductDetail(shipProductReq2);
    }

}
